<template>
  <div class="listWapper">
    <customDetailsTopbar title="消防重点部位" flag @back="back" />
    <div id="customScroolBox" class="listInner px-1">
      <customSearch ref="customSearch" placeholder="请输入企业名称" title="消防重点部位列表" :is-super-search="true" :total="total" @search="handleSearch" @superSearch="openSuperSearch" />
      <div v-if="tableList && tableList.length>0" class="common_list">
        <div v-for="(item,index) in tableList" :key="index" class="list_item" @click="goDetail(item)">
          <div class="content_area">
            <div class="number_order">{{ index + 1 }}</div>
            <div class="right_content">
              <div class="content_title" style="max-width: 100%">
                {{ item.companyName }}
              </div>
              <ul class="des-list">
                <li v-for="des,ind in desList" :key="des.value" class="des">
                  <i :class="'iconfont c-text-color' + ((ind % 7) + 1)" v-html="des.icon" />
                  <div class="label">{{ des.label }}：</div>
                  <div class="value">{{ item[des.value] }}</div>
                </li>
              </ul>
            </div>
          </div>
        </div>
        <!--        <el-empty v-if="tableList.length == 0" description="暂无数据" />-->
      </div>
      <customLoadmore ref="customLoadmore" :page-num="form.pageNum" :pages="pages" @load="handlePages" />
    </div>
    <van-popup v-model="superSearch" position="right" :style="{ width: '90%', height: '100%' }" lock-scroll close-on-popstate closeable class="custom-van-pop">
      <div class="pop-vertical-flex">
        <div class="pop-content">
          <div class="checkbox-title">部位名称</div>
          <el-input v-model="form.positionName" class="mb-1" placeholder="请输入部位名称" size="small" clearable />
          <customPopCheckbox :list="selectOptionAll['消防-房屋出租管理-耐火等级']" :check-value.sync="form.fireLevel" title="耐火等级" />
          <customPopCheckbox :list="selectOptionAll['消防-重点部位类型']" :check-value.sync="form.positionType" title="部位类型" />
        </div>
        <div class="pop-bottom">
          <van-button type="default" @click="resetSuperSearch">清空</van-button>
          <van-button type="info" @click="handleSuperSearch">确认</van-button>
        </div>
      </div>
    </van-popup>
  </div>
</template>

<script>
import commonList from '@/assets/mixin/commonList'
import { importantPositionList } from '@/api/fireFighting'
export default {
  mixins: [commonList],
  data() {
    return {
      total: 10,
      pages: 1,
      form: {
        companyName: '',
        fireLevel: '',
        companyIds: -1,
        positionType: '',
        pageNum: 1,
        pageSize: 10
      },
      desList: [
        { label: '部位名称', value: 'positionName', icon: '&#xe62c;' },
        { label: '耐火等级', value: 'fireLevel', icon: '&#xe6f7;' },
        { label: '部位类型', value: 'positionType', icon: '&#xe994;' },
        { label: '所属构筑物', value: 'belongStructure', icon: '&#xec54;' }
      ],
      tableList: [],
      current: ''
    }
  },
  mounted() {
    const { current } = this.$route.query
    this.current = current || ''
    this.importantPositionList()
  },
  methods: {
    back() {
      this.$router.push({
        path: '/staging/monitor',
        query: { current: this.current }
      })
    },
    async importantPositionList(flag) {
      this.$refs.customLoadmore.loadStatus = true
      // this.layout.showLoading()
      const { status, data } = await importantPositionList(this.form)
      if (status === 0 && data) {
        this.tableList = flag ? this.tableList.concat(data.list) : data.list
        this.total = data.total
        this.pages = data.pages
      }
      // this.layout.hideLoading()
      this.$refs.customLoadmore.loadStatus = false
    },
    goDetail(item) {
      this.$router.push({
        path: '/staging/riskMonitoringDetail',
        query: { current: this.current, positionId: item.positionId }
      })
    },
    handleSearch(val) {
      this.form.companyName = val
      this.tableList = []
      this.form.pageNum = 1
      this.importantPositionList()
    },
    handlePages(pageNum) {
      this.form.pageNum = pageNum
      this.importantPositionList(true)
    },
    resetSuperSearch() {
      Object.keys(this.form).forEach(v => {
        this.form[v] = ''
      })
      this.$refs.customSearch.restore()
      this.form.pageNum = 1
      this.form.pageSize = 10
      this.form.companyIds = -1
    },
    handleSuperSearch() {
      this.superSearch = false
      this.importantPositionList()
    }
  }
}
</script>

<style lang="scss" scoped>
.checkbox-title {
  font-size: 28px;
  font-weight: bold;
  margin-bottom: 30px;
}

.right_content{
  .des-list{
    display: flex;
    flex-wrap: wrap;
    .des{
      width: 100%;
    }
  }
}
</style>
